using EventHandlerDemo.Application.Orders;
using EventHandlerDemo.Application.Orders.EventHandlers;
using EventHandlerDemo.Domain.Orders.Events;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddMediatR(configuration =>
{
    configuration.RegisterServicesFromAssemblyContaining<OrderCreatedEvent>();
    configuration.RegisterServicesFromAssemblyContaining<OrderCreatedEventHandler>();
});
builder.Services.AddTransient<IOrderAppService, OrderAppService>();

var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseAuthorization();
app.MapControllers();
app.Run();